<!--
    group: 发票管理
    name: 申请开票
    url: /invoice/applyInvoice
-->
<template>
  <div>
    <div class="invoice_top">
      <div class="invoice_header">
        <h3 class="weight"><span class="icons"></span>申请开票</h3>
        <span class="surplus">年度剩余开票金额：{{ amountColumn.yearTotalMoney }}元</span>
      </div>
    </div>

    <!--展示审核驳回原因 -->
    <div class="invoice_top" v-if="form.bizStatus == 103">
      <div class="invoice_bottom red">
        <span class="weight">审核驳回：</span> {{ form.rejectReason }}
      </div>
    </div>

    <!-- 表单提交第一步 -->
    <div v-if="stepShow">
      <AddInvoiceCover
        :detailsData="detailsData.taxType ? detailsData : ''"
        @getRegistrationTime="getRegistrationTime"
        @handleStepFather="handleStepFather"
      />
    </div>
    <!-- 表单提交第二步 -->
    <div v-if="!stepShow" class="main_content">
      <a-form-model :model="form" ref="ruleForm"
                    :label-col="labelCol" :wrapper-col="wrapperCol"
                    :rules="rules"
      >
        <h4>业务说明</h4>
        <a-form-model-item label="业务结算周期" prop="time">
          <a-range-picker
            v-model="form.time"
            @change="onChange"
            format="YYYY-MM-DD HH:mm:ss"
            :disabledDate="disabledDate"
            :showTime="{defaultValue:[$moment('00:00:00', 'HH:mm:ss'), $moment('23:59:59', 'HH:mm:ss')]}"
          />
          <!--<span slot="help">99999999999999999999</span>-->
        </a-form-model-item>
        <a-form-model-item label="服务内容" prop="serviceContent">
          <a-input type="input" v-model="form.serviceContent" placeholder="请输入" />
          <span slot="help">软件开发</span>
        </a-form-model-item>
        <a-form-model-item label="需完成的项目" prop="project">
          <a-input type="input" v-model="form.project" placeholder="请输入" />
          <span slot="help">XXXX软件/系统/平台进行开发</span>
        </a-form-model-item>
        <a-form-model-item label="验收标准" prop="acceptanceCriteria">
          <a-input type="input" v-model="form.acceptanceCriteria" placeholder="请输入" />
          <span slot="help">根据每个阶段交付的源码以及提交的测试报告进行验收</span>
        </a-form-model-item>
        <a-form-model-item label="完成情况" prop="completionStatus">
          <a-input type="input" v-model="form.completionStatus" placeholder="请输入" />
          <span slot="help">现阶段已经完成XXX模块的开发，已交付源码以及对应测试报告，且验收合格</span>
        </a-form-model-item>
        <a-form-model-item label="结算数据说明" prop="dataDesc">
          <a-input type="input" v-model="form.dataDesc" placeholder="请输入" />
          <span slot="help">完成XXX模块的开发，支付开发费用XXXX元</span>
        </a-form-model-item>
        <a-form-model-item label="流水回单">
          <p-UpLoadFile ref="qyfzrxx_sign" v-model="form.businessInfo" :showHelp="false" :config="signConfig" :customRequestEvent="PUpLoadFileCustomRequestEvent" />
        </a-form-model-item>
        <a-form-model-item label="合同及补充材料" required :wrapperCol="{ span:16 }">
          <p-UpLoadFile ref="qsbkp_bccl" v-model="form.replenishInfo" :showHelp="true" :config="supplementConfig" :customRequestEvent="PUpLoadFileCustomRequestEvent" :extendedFileVerification="extendedFileVerification" />
        </a-form-model-item>

        <h4>发票开具说明</h4>
        <a-textarea v-model="form.taxRemark" placeholder="请输入" :rows="4" />

        <h4 style="margin-top: 30px;">请选择发票交付方式</h4>
        <div style="display: flex;align-items: center;">
          <a-form-model-item prop="deliveryMethod">
            <a-select v-model="form.deliveryMethod" @change="deliveryChange" placeholder="请选择发票交付方式" style="width: 180px;">
              <a-select-option :value="1">邮箱交付</a-select-option>
              <a-select-option :value="2">二维码交付</a-select-option>
              <a-select-option :value="3">线下交付</a-select-option>
              <a-select-option :value="4">勤税宝交付</a-select-option>
            </a-select>
          </a-form-model-item>
          <a-form-model-item prop="email" v-if="form.deliveryMethod == 1" class="mLeft">
           <a-auto-complete v-model="form.email" placeholder="请填写收取发票的邮箱地址"
              :data-source="emailData" :filter-option="filterOption" style="width: 250px;"
           />
          </a-form-model-item>
          <a-form-model-item prop="deliveryContent" v-if="form.deliveryMethod == 3" class="mLeft">
            <a-radio-group v-model="form.deliveryContent" style="display: flex;">
              <a-radio :value="'1'">下载为PDF</a-radio>
              <a-radio :value="'2'">下载为OFD</a-radio>
              <a-radio :value="'3'">下载为XML</a-radio>
            </a-radio-group>
          </a-form-model-item>
        </div>

      </a-form-model>
      <div class="main_footer">
        <a-button @click="referTo" type="primary" class="btnsLarge" v-preventReClick>提交开票申请</a-button>
        <a-button @click="prevStep" type="default" class="mLeft large">返回上一步</a-button>
        <a @click="saveDraft" v-if="form.bizStatus != 103" href="#" style="margin-left: 10px;text-decoration: underline;" v-preventReClick>保存草稿</a>
      </div>
    </div>

    <!-------------------------------------------------------------  提交成功弹层 ↓   -------------------------------------------------------->
    <a-modal
      :footer="null" :closable="false"
      v-model="invoiceVisible"
      :maskClosable="false"
      :keyboard="false"
    >
      <!--提交成功-->
      <a-result
         status="success"
         title="提交成功，开票申请已提交"
         sub-title="您可以在发票列表中查看审核进度"
      >
        <template #extra>
          <a-button key="buy" @click="back">返回列表</a-button>
        </template>
      </a-result>
      <!--end-->
    </a-modal>
    <!-------------------------------------------------------------  保存草稿成功提示 ↓   ---------------------------------------------->
    <ModalCurrency :config="undoConfig" @fatherMethod="fatherMethod" />
  </div>
</template>

<script>
import moment from "moment";
import Vue from "vue";
import { mapState } from 'vuex';
import {
  getTaxInvoiceDetails, saveTaxInvoice, saveTaxInvoiceTem,
  getEMailList, getEntMoneyInfo, invoiceApplication,
} from '@/api/invoiceAdminister'
import {
  conversionElement, percentConversion, conversionBranch,
  cloneObject, accSub, accAdd, limitDigits, copyLinkContent, percentageConverse
} from '@/utils/util'
import * as Regular from '@/views/invoice/utils/invoiceInputVerification'
import AddInvoiceCover from '@/views/invoice/modules/addInvoiceCover'
import ModalCurrency from '@views/invoice/common/modalCurrency'
export default {
  name: "applyInvoice",
  components:{
    AddInvoiceCover,
    ModalCurrency,
  },
  data(){
    return{
      id: null,  //企业id
      ticketType: null,  //开票类型 1-传统票 2-数电票 3-混合票
      stepShow: true,  //表单展示
      labelCol: { span: 4 },
      wrapperCol: { span: 10 },
      //年季月开票金额与限制金额
      amountColumn: {
        yearTotalMoney: 0,  //年度剩余开票金额
        yearLimit: 470000000,  //企业年度封顶金额470万元
      },

      form:{
        time: [],  //业务说明-业务结算周期
        serviceContent: '',  //业务说明-服务内容
        project: '',  //业务说明-需完成的项目
        acceptanceCriteria: '',  //业务说明-验收标准
        completionStatus: '',  //业务说明-完成情况
        dataDesc: '',  //业务说明-结算数据说明

        businessInfo: {},  //流水回单
        replenishInfo: {},  //合同及补充材料

        taxRemark: '',   //开票备注
        // billUseNum: null,   //开票数量
        deliveryMethod: 3,  //交付方式  1-邮箱交付 2-二维码交付 3-线下交付 4-勤税宝交付
        email: '',   //收件邮箱
        deliveryContent: null,  //交付内容式  1-下载为PDF 2-下载为OFD 3-下载为XML
      },
      rules:{
        time: [{ required: true, message: '请选择业务结算周期', trigger: 'change' }],
        serviceContent: [{ required: true, message: '请输入服务内容', trigger: 'blur' }],
        project: [{ required: true, message: '请输入需完成的项目', trigger: 'blur' }],
        acceptanceCriteria: [{ required: true, message: '请输入验收标准', trigger: 'blur' }],
        completionStatus: [{ required: true, message: '请输入完成情况', trigger: 'blur' }],
        dataDesc: [{ required: true, message: '请输入结算数据说明', trigger: 'blur' }],
        deliveryMethod: [{ required: true, message: '请选择发票交付方式', trigger: 'change' }],
        deliveryContent: [{ required: true, message: '请选择交付格式', trigger: 'change' }],
        email: [
          { required: false, message: '请输入收取发票的邮箱地址', trigger: 'blur' },
          { validator: Regular.validateEmail }
        ],
      },
      extendedFileVerification: [
        { 'groupName':'发票', suffixArr:[],errorMsg:'' },
        {
          'groupName':'开票上传补充资料',
          suffixArr:['jpg', 'png', 'jpeg', 'pdf','txt', 'xlsx', 'xls', 'doc', 'docx','pptx', 'ppt','zip', 'rar','ofd'],
          errorMsg:'只允许上传 图片文件压缩包 类型文件'
        }
      ],
      signConfig:{
        // 此参数必填  上传路径
        dir: "/qsb/invoice/",
        // 此参数必填 表示要采用什么模式   可选的值： 单文件  多文件  身份证  all  ；  单文件 对应 card1 ；   多文件 对应  card3 ； 身份证  对应  card1（身份证正面）、card2（身份证反面）
        model: "单文件",
        // 此参数选填   文件上传必填校验 默认为false 不校验   当值为true时进行强制校验  需要配合【getDataCheckRes】方法使用；
        // 方法【getDataCheckRes】的具体用法如: this.$refs.UpLoadFile.getDataCheckRes({ card1: "请上传身份证正面",card2: "请上传身份证反面", card3: "请上传附件"});
        // 其中 【getDataCheckRes】的参数辨识检验不通过时对应的提示信息；card1、card2、card3均可缺省，也可选填对应的字段    此参数可空
        required: false,
        tips:{
          card1: '上传流水回单',
        },
        // 此参数选填   要回显的数据 card1 card2 的值的格式为：{name:'',url:''} ;  card3 的值的格式为 [{name:'',url:''}，{name:'',url:''}]
        defaultFileList: {
          card1: {},
        },
        // 此参数集必填
        fielConfig: {
          type: "发票",
          size: 1,
          singleFileSize: 10,
        },
      }, //上传流水回单
      supplementConfig:{
        // 此参数必填  上传路径
        dir: "/qsb/invoice/",
        // 此参数必填 表示要采用什么模式   可选的值： 单文件  多文件  身份证  all  ；  单文件 对应 card1 ；   多文件 对应  card3 ； 身份证  对应  card1（身份证正面）、card2（身份证反面）
        model: "多文件",
        // 此参数选填   文件上传必填校验 默认为false 不校验   当值为true时进行强制校验  需要配合【getDataCheckRes】方法使用；
        // 方法【getDataCheckRes】的具体用法如: this.$refs.UpLoadFile.getDataCheckRes({ card1: "请上传身份证正面",card2: "请上传身份证反面", card3: "请上传附件"});
        // 其中 【getDataCheckRes】的参数辨识检验不通过时对应的提示信息；card1、card2、card3均可缺省，也可选填对应的字段    此参数可空
        required: true,
        tips:{
          card3: '上传合同及补充材料',
        },
        // 此参数选填   要回显的数据 card1 card2 的值的格式为：{name:'',url:''} ;  card3 的值的格式为 [{name:'',url:''}，{name:'',url:''}]
        defaultFileList: {
          card3: [],
        },
        // 此参数集必填
        fielConfig: {
          type: "开票上传补充资料",
          size: 100,  //文件个数限制
          singleFileSize: {
            "jpg":5,"png":5, "jpeg":5,
            "pdf":10,"txt":10, "xlsx":10,
            "xls":10,"doc":10, "docx":10,
            "pptx":10,"ppt":10, "ofd":10,
            "rar":100, "zip":100,
          },
        },
      }, //上传合同及补充材料
      registrationTime: null,//企业注册时间
      emailData: [],  //邮箱地址列表
      invoiceVisible: false,   //成功提示弹层
      timer: null,  // 定时器名称
      detailsData:{},  //详情
      detailsId: null,   //发票id
      //保存草稿成功
      undoConfig:{
        width: '500px',  //modal宽度
        visible: false,    //modal展示状态
        modalTitle: '',   //modal层的标题
        icon: 'check-circle',
        iconColor: '#52c41a',
        iconSize: '35',
        title: '保存成功！',     //标题
        subTitle: '',     //副标题
        content: '您可以在草稿箱查看或直接提交。',  //内容
        okText: '提交开票申请',    //确定文字
        okType: 'default',    //确定类型
        cancleText: '返回发票列表',    //取消文字
        cancleType: 'primary',    //取消类型

        source: 5,    //来源  ''发送成功  1撤销并删除 2邀请验证 3确认寄送 4删除草稿 5保存草稿
        cancleRoute: '/invoice/invoiceQueryNew',     //跳转路由
      },

      //变更申请
      varyType: null,  // 1-详情变更申请
    }
  },
  created() {
    this.id = this.$route.query.bizId;

    //detailsId 根据这个字段判定是否需要补充资料，调取详情接口
    if (this.$route.query.detailsId){
      this.getListDetails(this.$route.query.detailsId);
    }
    //从详情 变更申请 发起
    if (this.$route.query.varyType){
      this.varyType = this.$route.query.varyType;
    }
  },
  mounted() {
    this.getMoneyInfo();   //获取开票金额
    this.getEmailList();   //查询邮箱信息
  },
  computed:{
    ...mapState({
      totalPrice: state => state.invoice.totalPrice,  //开票总金额
    }),
  },
  watch:{
    totalPrice(currVal) {
      // 监听mapState中的变量，当数据变化（有值、值改变等），
      // 保证能拿到完整的数据，不至于存在初始化没有数据的问题，然后可以赋给本组件data中的变量
      this.form.totalPrice = currVal;

      // let data = cloneObject(currVal);
      // let a = conversionBranch(data);
      // let b = accAdd(a,this.amountColumn.quarterMoney); //获取当季度已开金额
      // this.form.quarterTotalPrice = conversionElement(b);
      // let c = accAdd(a,this.amountColumn.monthMoney); //获取月度已开金额
      // this.form.totalMonthPrice = conversionElement(c);
    },
  },
  methods:{
    //选择发票交付方式
    deliveryChange(value) {
      //交付方式  1-邮箱交付 2-二维码交付 3-线下交付 4-勤税宝交付
      if (value == 1){
        this.rules.email[0].required = true;
        this.form.deliveryContent = '';
      }else if(value == 3){
        this.rules.deliveryContent[0].required = true;
        this.form.email = '';
      }else{
        this.rules.email[0].required = false;
        this.rules.deliveryContent[0].required = false;
        this.form.deliveryContent = '';
        this.form.email = '';
      }
    },
    //  ---------------------------- 表单分布提交 ↓ ---------------------------
    //表单第一步提交返回数据
    handleStepFather(data,digitalInfo){
      const tempFileInfo = this.form.businessInfo
      this.form = {...this.form,...data,businessInfo:tempFileInfo};
      if(tempFileInfo && tempFileInfo.card1 && tempFileInfo.card1.url){
        this.signConfig.defaultFileList = tempFileInfo
      }

      this.detailsData = data;
      // this.ticketMargin = ticketMargin;
      this.ticketType = digitalInfo.ticketType; //开票类型 1-传统票 2-数电票 3-混合票
      this.amountColumn.digitalMonthLimit = digitalInfo.digitalMonthLimit; //数电月度最大限额
      this.stepShow = false;
    },
    //返回上一步
    prevStep(){
      this.stepShow = true;
    },
    //  ---------------------------- 保存草稿功能 ↓ -------------------------------
    //保存草稿
    saveDraft(){
      let data = this.getParamData();
      //处理开票内容
      if (data.taxContents.length > 0){
        for (let k=0; k<data.taxContents.length; k++) {
          data.taxContents[k].num = Math.floor(parseInt(data.taxContents[k].num));

          if (!data.taxContents[k].invoiceTypeName && data.taxContents[k].name && data.taxContents[k].value){
            data.taxContents[k].invoiceTypeName = data.taxContents[k].name + '*' + data.taxContents[k].value;
          }
        }
      }

      saveTaxInvoiceTem(data).then(res => {
        if (res.success) {
          this.detailsId = res.result;
          //将vuex税率重置
          this.$store.dispatch('deleteInvoiceVat');
          //保存草稿成功
          this.$nextTick(()=>{
            this.undoConfig.visible = true;
          })
        }else{
          this.$message.warning(res.message);
        }
      })
    },
    //保存草稿成功跳转路径
    fatherMethod(config) {
      //确定撤销
      this.$nextTick(() => {
        this.undoConfig.visible = false;
      })
      this.form.id = this.detailsId;   //提交开票申请传入发票id
      //调取提交开票申请方法
      this.referTo();
    },
    //  ------------------------------ 保存提交处理 ↓ -----------------------------
    //处理提交参数
    getParamData(){
      let data = cloneObject(this.form);
      data.entId = this.id;
      if (this.$route.query.detailsId){

      }else{
        data.ticketType = this.ticketType; //开票类型 1-传统票 2-数电票 3-混合票
      }
      //判断增值税率与文件格式上传
      if (data.taxType == 2){
        Vue.delete(data,'vatIndex');   //普票不传增值税字段
      }else {
        if (data.vatRateTem != 3){
          Vue.delete(data,'vatReason');   //专票税率不是3%不传原因
        }
      }

      //处理开票内容
      for (const key in data.taxContents) {
        data.taxContents[key].money = parseInt(conversionBranch(data.taxContents[key].money));
        data.taxContents[key].unitPrice = parseInt(conversionBranch(data.taxContents[key].unitPrice));
      }
      //处理流水回单上传
      const fileInfo = this.form.businessInfo.card1;
      if(fileInfo && fileInfo && fileInfo.url){
        data.certificate = [{
          fileName: fileInfo.name,
          fileUrl: fileInfo.url
        }];
      }
      //处理合同及补充材料
      const meansInfo = this.form.replenishInfo.card3;
      if(meansInfo && meansInfo.length > 0){
        let arryNew = [];
        meansInfo.map((item, index) => {
          arryNew.push(Object.assign({}, item, { fileName: item.name, fileUrl: item.url }));
          return arryNew;
        });
        data.replenishMaterial = arryNew
      }else{
        data.replenishMaterial = [];
      }

      return data;
    },
    //提交开票申请
    referTo(){
      const check_qsbkp_bccl = this.$refs['qsbkp_bccl'].getDataCheckRes({ card3: "请上传合同及补充材料"});
      if (JSON.stringify(check_qsbkp_bccl).indexOf(false) >= 0) {
        this.$message.warning('请检查是否上传合同及补充材料');
        return false;
      }

      this.$refs.ruleForm.validate(valid => {
        if (valid) {
          if (this.varyType == 1){
            //变更申请请求接口
            this.getApplication();
          }else {//提交开票申请接口
            this.submitInvoiceInterface();
          }
        }else {
          return false;
        }
      })
    },
    //提交开票申请接口
    submitInvoiceInterface(){
      let params;
      params = this.getParamData();
      saveTaxInvoice(params).then(res => {
        if (res.success) {
          //提交成功
          this.invoiceVisible = true;
          // 重置state
          this.$store.state.invoice.amountNum = 0;
          //将vuex税率重置
          this.$store.dispatch('deleteInvoiceVat');
        }else{
          this.$message.warning(res.message);
        }
      })
    },
    //变更申请请求接口
    getApplication(){
      let params = {};
      params = this.processingData();
      invoiceApplication(params).then(res => {
        if (res.success) {
          //提交成功
          this.invoiceVisible = true;
          // 重置state
          this.$store.state.invoice.amountNum = 0;
          //将vuex税率重置
          this.$store.dispatch('deleteInvoiceVat');
        } else {
          this.$message.warning(res.message);
        }
      })
    },
    //处理数据金额
    processingData(){
      let newData = cloneObject(this.form);

      for (const key in newData.taxContents) {
        newData.taxContents[key].money = conversionBranch(newData.taxContents[key].money);
        newData.taxContents[key].unitPrice = conversionBranch(newData.taxContents[key].unitPrice);
      }

      return newData;
    },
    //返回列表
    back(){
      this.$router.push({
        path: '/invoice/invoiceQueryNew'
      })
    },
    //  ---------------------------- 获取获取开票金额 ↓ --------------------
    //获取开票金额
    getMoneyInfo() {
      let entId = this.id;
      getEntMoneyInfo(entId).then(res => {
        if (res.success) {
          let data = res.result;
          if (data) {
            let dataNew = cloneObject(data);
            this.amountColumn.yearTotalMoney = conversionElement(dataNew.yearBalanceMoney); //年度剩余开票金额
          }
        } else {
          this.$message.warning(res.message);
        }
      })
    },
    //  ---------------------------- 补充资料初始数据获取 ↓ --------------------------
    //查看详情
    getListDetails(id){
      getTaxInvoiceDetails(id).then(res => {
        if (res.success) {
          if (res.result){
            let data = res.result;

            //判断拒绝状态领用数量重新计算
            if(data.bizStatus == 103){
              // 删除领用对象
              Vue.delete(data,'billSegment');
            }

            //将税率存储vuex
            let str = {};
            if (data.taxType == 2){
              str.vatRate = 1;
            }else{
              str.vatRate = data.vatRateTem;
            }
            str.vatIndex = data.vatIndex;
            this.$store.dispatch('setInvoiceVatIndex', str);
            //存储发票类型
            this.$store.dispatch('setInvoiceType', data.taxType);

            //处理开票金额
            if (data.taxContents.length > 0){
              let newTaxContents = cloneObject(data.taxContents);
              for (let key=0; key<newTaxContents.length; key++) {
                data.taxContents[key].money = conversionElement(newTaxContents[key].money);
                data.taxContents[key].unitPrice = conversionElement(newTaxContents[key].unitPrice);
              }
            }else{
              data.taxContents = [  //开票内容
                {
                  invoiceTypeCode: null,   //发票类目
                  invoiceTypeName: null,
                  isShow: true,
                  ultraLimit: null,  //是否超出企业设置的经营范围  1 是  0否
                  money: null,   //发票金额（不含税）
                  taxMoney: null,   //发票金额（含税）
                  unit: null,   //单位
                  spec: null,   //规格型号
                  num: null,   //数量
                  unitPrice: null,   //单价
                  nameGenre: null,  //其他类别
                  name: null,
                  value: null,
                }
              ];
            }
            this.detailsData = data;

            this.form = data;

            //根据交付方式校验必填项
            if (this.form.deliveryMethod == 1){
              this.rules.email[0].required = true;
              this.form.deliveryContent = '';
            }else if (this.form.deliveryMethod == 3){
              this.rules.email[0].required = false;
              this.rules.deliveryContent[0].required = true;
              this.form.email = '';
            }else{
              this.rules.email[0].required = false;
              this.rules.deliveryContent[0].required = false;
              this.form.email = '';
              this.form.deliveryContent = '';
            }

            //业务说明时间
            //强制修改数值改变 新增属性,又可以触发视图更新。
            this.$set(this.form, 'time', [moment(this.form.bizSettleAccountsCycleStart),moment(this.form.bizSettleAccountsCycleEnd)]);
            //流水回单文件回显
            if (this.form.certificate && this.form.certificate.length > 0){
              this.signConfig.defaultFileList.card1 = {name:this.form.certificate[0].fileName,url:this.form.certificate[0].fileUrl}
            }

            //合同及补充材料回显
            if (this.form.replenishMaterial && this.form.replenishMaterial.length > 0){
              let arryNew = [];
              this.form.replenishMaterial.map((item, index) => {
                arryNew.push(Object.assign({}, item, { name: item.fileName, url: item.fileUrl }));
                return arryNew;
              });
              this.supplementConfig.defaultFileList.card3 = arryNew;
            }

          }
        }else{
          this.$message.warning(res.message);
        }
      })
    },
    //  ---------------------------- 业务说明相关处理 ↓ ---------------------------
    //从子组件获取企业注册时间
    getRegistrationTime(time){
      this.registrationTime = time;
    },
    //业务说明周期开始时间小于企业注册时间
    disabledDate(cur) {
      //   return current && current < moment().subtract(1, 'days').endOf('day');    //小于今天之前不可选择
      // const now = moment().format('YYYY-MM-DD') + ' 00:00:00'
      //获取当前时间
      const now = this.registrationTime;
      let dateT = moment(now).valueOf()
      //置灰日期小于当前时间
      return cur < dateT
    },
    //业务结算周期选择
    onChange(date, dateString) {
      this.form.bizSettleAccountsCycleStart = dateString[0];
      this.form.bizSettleAccountsCycleEnd = dateString[1];
    },
    //  ---------------- 选择邮箱信息 --------------
    //查询邮箱信息
    getEmailList(){
      let entId = this.id;
      getEMailList(entId).then(res => {
        if (res.success) {
          let data = res.result;
          if (data){
            let newList = [];
            data.forEach((item) => {
              newList.push(
                item.email
              );
            });
            this.emailData = newList;
          }
        }else{
          this.$message.warning(res.message);
        }
      })
    },
    //自动搜索邮箱
    filterOption(input, option) {
      return (
        option.componentOptions.children[0].text.toUpperCase().indexOf(input.toUpperCase()) >= 0
      );
    },
    //  ---------------------------- 规则 ↓ --------------------
    //分转元
    scalerPrice(money){
      return conversionElement(money);
    },
    //百分比转换    0.6 => 60%
    scalerSign(num){
      return percentConversion(num);
    },
  },
  beforeDestroy() {
    clearInterval(this.timer);
    this.timer = null;
    //将vuex税率重置
    this.$store.dispatch('deleteInvoiceVat');
  }
}
</script>

<style scoped lang="less">
//公共
.weight{ font-weight: bold; }
h4{ font-weight: bolder;font-size: 16px; }
.large{
  width: 276px;
  height: 44px;
  border: 1px solid #4266E5;
  color: #4266E5;
  border-radius: 2px;
}

.invoice_top{
  margin-bottom: 10px;
  .invoice_header{
    background: #FFFFFF;
    padding: 10px 24px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .surplus{
      color: @color-lightGary;
    }
  }
  .invoice_bottom{
    background: #FFFFFF;
    padding: 10px 24px;
    width: 100%;
  }
  h5 {
    text-align: center;
    font-size: 16px;
    color: @color-red;

    button {
      margin: 0 10px;
    }
  }

}


////
.remarks{color: #101010;margin: 20px 0;}

//预估费用
.estimated{
  width: 100%;
  h5{
    font-weight: bolder;
    font-size: 16px;
  }
}
//提交成功
/deep/.ant-result-success .ant-result-icon > .anticon{
  color: @color-blue;
}

//弹层公共样式
.desc_name{
  color: #101010;
}
.desc_explain{
  width: 100%;
  padding: 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.desc_footer{
  width: 100%;
  padding: 5px 10px;
  //background: #F9F8F9;
  //border: 1px solid #dee0e2;
  //border-radius: 10px;
  margin-bottom: 20px;
  p{
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .price{
    color: @color-blue;
  }
}
.desc_btn{
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  margin: 40px 0 20px 0;
  text-align: center;
}
.desc_btn a{
  margin-left: 10px;
  //text-decoration: underline;
}

//金额超限
.exceedLimit{
  width: 100%;
  padding: 20px 10px;
  color: #101010;
  h4{
    display: flex;
    align-items: center;
    font-weight: bolder;
    font-size: 20px;
    padding-left: 30px;
    margin-bottom: 20px;
    i{
      color: @color-orange;
      font-size: 50px;
      margin-right: 10px;
    }
  }
  .describe{
    margin-bottom: 20px;
    padding-left: 40px;
    font-size: 18px;
    line-height: 30px;
  }
}

//选择核定方式
.methodVerification{
  h4{
    display: flex;
    align-items: flex-start;
    font-weight: bolder;
    font-size: 20px;
    padding-left: 30px;
    margin-bottom: 20px;
    i{
      color: @color-orange;
      font-size: 50px;
      margin-right: 10px;
    }
  }
  .ratify{
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    border: 1px solid #dee0e2;
    color: #101010;
    .ratify_item{
      width: 100%;
      display: flex;
      align-items: center;
      .item{
        text-align: center;
        height: 100%;
        padding: 5px 0;
        display: inline-block;
      }
      .item_one{width: 50px;display: flex;align-items: center;justify-content: center;}
      .item_two{
        flex: 2;
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        align-items: center;
        span{
          width: 100%;
        }
        .sell{
          width: 60px;
          background: @color-blue;
          font-size: 14px;
          border-radius: 20px;
          line-height: 28px;
          color: #FFFFFF;
          display: block;
        }
        .middle_tax{
          margin-top: 10px;
          width: 100%;
          text-align: center;
          color: @color-blue;
        }
      }
      .item_three{flex: 3;padding-left: 10px;}
      .desc{
        width: 100%;
        text-align: left;
        box-sizing: border-box;
        padding-top: 20px;
        span{
          display: block;
        }
      }
      .item_one,.item_two{
        border-right: 1px solid #dee0e2;
      }
    }
    .ratify_item:nth-child(1){
      background: #F8F8F8;
      border-bottom: 1px solid #dee0e2;
      font-weight: bolder;
    }
    .ratify_item:nth-child(2){
      border-bottom: 1px solid #dee0e2;
      //border: 2px solid @color-green;
      background: #eef1fd;
    }
  }
  .tips{
    width: 100%;
    //text-align: center;
    margin-top: 10px;
    margin-left: 5px;
    color: @color-lightGary;
    //font-weight: bolder;
  }



}
.blue{
  color: @color-blue;
}

//资料补充
.supplement{
  width: 100%;
  h4{
    display: flex;
    align-items: center;
    font-weight: bolder;
    padding-left: 30px;
    margin-bottom: 20px;
    p{
      font-size: 18px;
      margin-bottom: 0;
    }
    i{
      color: @color-orange;
      font-size: 50px;
      margin-right: 10px;
    }
  }
  .byte{
    display: inline-block;
    color: @color-blue;
  }

  .item_content{
    width: 100%;
    padding: 10px 23px;
    border-radius: 10px;
    border: 1px solid rgba(187, 187, 187, 1);
    margin-top: 20px;

    .item_header{
      width: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    .item_bottom{
      width: 100%;
      padding-top: 20px;
    }
  }

  .active{
    //border: 1px solid #4266E5;
  }
  .afterborder{
    border: 1px solid #4266E5;
    background: rgba(233,243,255,.6);
  }
}

//生成业务
.business{
  h4{
    display: flex;
    align-items: center;
    font-weight: bolder;
    font-size: 20px;
    padding-left: 30px;
    margin-bottom: 20px;
    i{
      color: @color-blue;
      font-size: 50px;
      margin-right: 10px;
    }
  }

  .business_item{
    width: 100%;
    //background: #F9F8F9;
    border-bottom: 1px solid #dee0e2;
    //border-radius: 10px;
    padding: 20px 10px;
    //margin-top: 20px;
    color: #101010;
    h6{
      color: #101010;
      font-weight: bolder;
      font-size: 14px;
      margin-bottom: 20px;
    }
    .business_name{
      display: inline-block;
      width: 100px;
      text-align: right;
      font-size: 14px;
      color: #999999;
      //font-weight: bolder;
    }
    .last_item{
      margin-bottom: 0;
    }
    .business_btn{
      margin-bottom: 5px;
      width: 100%;
      text-align: right;
    }
  }
}

//数电发票超月度限额提示弹层
.codeBox{
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  h3{
    width: 100%;
    text-align: center;
    font-weight: bold;
  }
  .code{
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    img{
      width: 220px;
    }
  }
}

</style>
